<%@ page language="java" import="java.util.*" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@include file="/context/mytags.jsp" %>
<!DOCTYPE html>
<html>
<head>
    <title>E卡返点</title>
    <t:base type="jquery,easyui,tools,DatePicker"></t:base>
    <link type="text/css" href="plug-in/Validform/css/metrole/style.css" rel="stylesheet">
    <link type="text/css" href="plug-in/Validform/css/metrole/tablefrom.css" rel="stylesheet">
    <script src="plug-in/Validform/js/Validform_v5.3.1_min_zh-cn.js" type="text/javascript"></script>
    <script src="plug-in/Validform/js/Validform_Datatype_zh-cn.js" type="text/javascript"></script>
    <script src="plug-in/Validform/js/datatype_zh-cn.js" type="text/javascript"></script>
    <script src="plug-in/Validform/plugin/passwordStrength/passwordStrength-min.js" type="text/javascript"></script>
</head>
<body style="overflow-y: auto" scroll="no">
<form id="rebate_return" action="mallEcardRebateController.do?audit" method="post">
    <input type="hidden" value="${rebate.id}" name="id">
    <input type="hidden" value="${rebate.state}" name="state" id="state">
    <table style="width: 100%" cellpadding="0" cellspacing="1" class="formtable">
        <c:set value="0" var="totalMoney"/>
        <c:set value="0" var="actualPayTotalMoney"/>
        <c:forEach var="order" items="${orderDetail}" varStatus="mapStatus">
            <c:set var="totalMoney" value="${totalMoney + order.key.paymoney}"/>
            <c:set var="actualPayTotalMoney" value="${actualPayTotalMoney + order.key.actualPayMoney}"/>
            <tr>
                <td colspan="6" style="text-align: center">订单信息</td>
            </tr>
            <tr>
                <td align="right">
                    <label class="Validform_label">
                            ${mapStatus.index + 1}:&nbsp;&nbsp;&nbsp;&nbsp;订单编号:
                    </label>
                </td>
                <td class="value">
                    <span class="">${order.key.orderno}</span>
                </td>
                <td align="right">
                    <label class="Validform_label">
                        所属店铺:
                    </label>
                </td>
                <td class="value">
                    <span class="">${order.key.shop.shopname}</span>
                </td>
                <td align="right">
                    <label class="Validform_label">
                        订单类型:
                    </label>
                </td>
                <td class="value">
				<span class="">
					<input type="hidden" id="order_type" value="${order.key.ordertype}">
					<c:if test="${order.key.ordertype == 0}">
                        线上商城订单
                    </c:if>
					<c:if test="${order.key.ordertype == 1}">
                        本地服务订单
                    </c:if>
					<c:if test="${order.key.ordertype == 2}">
                        在线充值服务订单
                    </c:if>
				</span>
                </td>
            </tr>
            <tr>
                <td align="right">
                    <label class="Validform_label">
                        商品金额:
                    </label>
                </td>
                <td class="value">
                    <span class="">${order.key.productmoney}</span>
                </td>
                <td align="right">
                    <label class="Validform_label">
                        订单金额:
                    </label>
                </td>
                <td class="value">
                    <span class="">${order.key.paymoney}</span>
                </td>
                <td align="right">
                    <label class="Validform_label">
                        实际支付金额:
                    </label>
                </td>
                <td class="value">
                    <span class="">${order.key.actualPayMoney}</span>
                </td>
            </tr>
            <tr>
                <td align="right">
                    <label class="Validform_label">
                        买家:
                    </label>
                </td>
                <td class="value">
                    <span class="">${order.key.user.fullname}</span>
                </td>
                <td align="right">
                    <label class="Validform_label">
                        创建时间:
                    </label>
                </td>
                <td class="value">
                    <span class=""><fmt:formatDate value='${order.key.createtime}' type="date"
                                                   pattern="yyyy-MM-dd HH:mm:ss"/></span>
                </td>
                <td align="right">
                    <label class="Validform_label">
                        支付时间:
                    </label>
                </td>
                <td class="value">
                    <span class=""><fmt:formatDate value='${order.key.paytime}' type="date"
                                                   pattern="yyyy-MM-dd HH:mm:ss"/></span>
                </td>
            </tr>
            <tr>
                <td colspan="6" style="text-align: center">订单详情</td>
            </tr>
            <c:forEach var="detail" items="${order.value}" varStatus="status">
                <%--线上商城订单--%>
                <c:if test="${order.key.ordertype == 0}">
                    <tr>
                        <td align="right">
                            <label class="Validform_label">
                                商品名称:
                            </label>
                        </td>
                        <td class="value">
                            <span class="">${detail.productname}</span>
                        </td>
                        <td align="right">
                            <label class="Validform_label">
                                商品编码:
                            </label>
                        </td>
                        <td class="value">
                            <span class="">${detail.productcode}</span>
                        </td>
                        <td align="right">
                            <label class="Validform_label">
                                数量:
                            </label>
                        </td>
                        <td class="value">
                            <span class="">${detail.amount}</span>
                        </td>
                    </tr>
                    <tr>
                        <td align="right">
                            <label class="Validform_label">
                                小计:
                            </label>
                        </td>
                        <td class="value">
                            <span class="">${detail.productfinalmoney}</span>
                        </td>
                        <td align="right">
                            <label class="Validform_label">
                                补贴类型:
                            </label>
                        </td>
                        <td class="value">
                            <c:if test="${detail.subsidytype != null && detail.subsidytype == 1}">
                                金额
                            </c:if>
                            <c:if test="${detail.subsidytype != null && detail.subsidytype == 2}">
                                折扣
                            </c:if>
                            <c:if test="${detail.subsidytype != null && detail.subsidytype == 3}">
                                满减
                            </c:if>
                        </td>
                        <td align="right">
                            <label class="Validform_label">
                                补贴金额:
                            </label>
                        </td>
                        <td class="value">
                            <span class="">${detail.subsidymoney}</span>
                        </td>
                    </tr>
                    <c:if test="${status.index == order.value.size() - 1}">
                        <tr>
                            <td align="right">
                                <label class="Validform_label">
                                    订单状态:
                                </label>
                            </td>
                            <td class="value" colspan="6">
                                <input type="hidden" id="order_status_${mapStatus.index}"
                                       value="${detail.mallOrderB2cEntity.orderstatus}">
                                <span class="">${detail.mallOrderB2cEntity.orderStatusName}</span>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="6" style="text-align: center">收货地址</td>
                        </tr>
                        <tr>
                            <td align="right">
                                <label class="Validform_label">
                                    收货人:
                                </label>
                            </td>
                            <td class="value">
                                <span class="">${detail.mallOrderB2cEntity.consigneename}</span>
                            </td>
                            <td align="right">
                                <label class="Validform_label">
                                    收货人电话:
                                </label>
                            </td>
                            <td class="value">
                                <span class="">${detail.mallOrderB2cEntity.mobilephone}</span>
                            </td>
                            <td align="right">
                                <label class="Validform_label">
                                    收货地址:
                                </label>
                            </td>
                            <td class="value">
                                <span class="">${detail.mallOrderB2cEntity.areacodeStr}${detail.mallOrderB2cEntity.detailaddress}</span>
                            </td>
                        </tr>
                    </c:if>
                </c:if>
                <%--本地服务订单--%>
                <c:if test="${order.key.ordertype == 1}">
                    <tr>
                        <td align="right">
                            <label class="Validform_label">
                                商品名称:
                            </label>
                        </td>
                        <td class="value">
                            <span class="">${detail.productname}</span>
                        </td>
                        <td align="right">
                            <label class="Validform_label">
                                商品编码:
                            </label>
                        </td>
                        <td class="value">
                            <span class="">${detail.productcode}</span>
                        </td>
                        <td align="right">
                            <label class="Validform_label">
                                数量:
                            </label>
                        </td>
                        <td class="value">
                            <span class="">${detail.amount}</span>
                        </td>
                    </tr>
                    <tr>
                        <td align="right">
                            <label class="Validform_label">
                                小计:
                            </label>
                        </td>
                        <td class="value">
                            <span class="">${detail.productfinalmoney}</span>
                        </td>
                        <td align="right">
                            <label class="Validform_label">
                                补贴类型:
                            </label>
                        </td>
                        <td class="value">
                            <c:if test="${detail.subsidytype != null && detail.subsidytype == 1}">
                                金额
                            </c:if>
                            <c:if test="${detail.subsidytype != null && detail.subsidytype == 2}">
                                折扣
                            </c:if>
                            <c:if test="${detail.subsidytype != null && detail.subsidytype == 3}">
                                满减
                            </c:if>
                        </td>
                        <td align="right">
                            <label class="Validform_label">
                                补贴金额:
                            </label>
                        </td>
                        <td class="value">
                            <span class="">${detail.subsidymoney}</span>
                        </td>
                    </tr>
                    <tr>
                        <td align="right">
                            <label class="Validform_label">
                                订单状态:
                            </label>
                        </td>
                        <td class="value">
                            <input type="hidden" id="order_status_${mapStatus.index}"
                                   value="${detail.mallOrderO2oEntity.orderstatus}">
                            <span class="">${detail.mallOrderO2oEntity.orderStatusName}</span>
                        </td>
                        <td align="right">
                            <label class="Validform_label">
                                短信接受手机:
                            </label>
                        </td>
                        <td class="value">
                            <span class="">${detail.mallOrderO2oEntity.mobilephone}</span>
                        </td>
                        <td align="right">
                            <label class="Validform_label">
                                消费时间:
                            </label>
                        </td>
                        <td class="value">
                            <span class=""><fmt:formatDate value='${detail.mallOrderO2oEntity.consumetime}' type="date"
                                                           pattern="yyyy-MM-dd HH:mm:ss"/></span>
                        </td>
                    </tr>
                </c:if>
                <%--在线充值服务订单--%>
                <c:if test="${order.key.ordertype == 2}">
                    <tr>
                        <td align="right">
                            <label class="Validform_label">
                                商品名称:
                            </label>
                        </td>
                        <td class="value">
                            <span class="">${detail.productname}</span>
                        </td>
                        <td align="right">
                            <label class="Validform_label">
                                商品编码:
                            </label>
                        </td>
                        <td class="value">
                            <span class="">${detail.productcode}</span>
                        </td>
                        <td align="right">
                            <label class="Validform_label">
                                数量:
                            </label>
                        </td>
                        <td class="value">
                            <span class="">${detail.amount}</span>
                        </td>
                    </tr>
                    <tr>
                        <td align="right">
                            <label class="Validform_label">
                                小计:
                            </label>
                        </td>
                        <td class="value">
                            <span class="">${detail.productfinalmoney}</span>
                        </td>
                        <td align="right">
                            <label class="Validform_label">
                                补贴类型:
                            </label>
                        </td>
                        <td class="value">
                            <c:if test="${detail.subsidytype != null && detail.subsidytype == 1}">
                                金额
                            </c:if>
                            <c:if test="${detail.subsidytype != null && detail.subsidytype == 2}">
                                折扣
                            </c:if>
                            <c:if test="${detail.subsidytype != null && detail.subsidytype == 3}">
                                满减
                            </c:if>
                        </td>
                        <td align="right">
                            <label class="Validform_label">
                                补贴金额:
                            </label>
                        </td>
                        <td class="value">
                            <span class="">${detail.subsidymoney}</span>
                        </td>
                    </tr>
                    <tr>
                        <td align="right">
                            <label class="Validform_label">
                                订单状态:
                            </label>
                        </td>
                        <td class="value">
                            <input type="hidden" id="order_status_${mapStatus.index}"
                                   value="${detail.mallOrderVirtualEntity.orderstatus}">
                            <span class="">${detail.mallOrderVirtualEntity.orderStatusName}</span>
                        </td>
                        <td align="right">
                            <label class="Validform_label">
                                卡号:
                            </label>
                        </td>
                        <td class="value">
                            <span class="">${detail.mallOrderVirtualEntity.cardno}</span>
                        </td>
                        <td align="right">
                            <label class="Validform_label">
                                通知电话:
                            </label>
                        </td>
                        <td class="value">
                            <span class="">${detail.mallOrderVirtualEntity.noticephone}</span>
                        </td>
                    </tr>
                </c:if>
            </c:forEach>
            <%--返点信息--%>
            <c:if test="${mapStatus.index == orderDetail.size() - 1}">
                <tr>
                    <td colspan="6" style="text-align: center">返点信息</td>
                </tr>
                <tr>
                    <td align="right">
                        <label class="Validform_label">
                            订单总金额:
                        </label>
                    </td>
                    <td class="value">
                        <span class="">${totalMoney}</span>
                    </td>
                    <td align="right">
                        <label class="Validform_label">
                            实际支付总金额:
                        </label>
                    </td>
                    <td class="value">
                        <span class="">${actualPayTotalMoney}</span>
                    </td>
                    <td align="right">
                        <label class="Validform_label">
                            返点类型:
                        </label>
                    </td>
                    <td class="value">
						<span class="">
							<c:if test="${rebate.rebatetype == 0}">按点返</c:if>
							<c:if test="${rebate.rebatetype == 1}">按金额</c:if>
						</span>
                    </td>
                </tr>
                <tr>
                    <td align="right">
                        <label class="Validform_label">
                            返点点数:
                        </label>
                    </td>
                    <td class="value">
                        <span class="">${rebate.rebatenum}</span>
                    </td>
                    <td align="right">
                        <label class="Validform_label">
                            返点金额:
                        </label>
                    </td>
                    <td class="value">
                        <span class="">${rebate.rebatemoney}</span>
                    </td>
                    <td align="right">
                        <label class="Validform_label">
                            返点时间:
                        </label>
                    </td>
                    <td class="value">
                        <span class=""><fmt:formatDate value='${rebate.rebatetime}' type="date"
                                                       pattern="yyyy-MM-dd HH:mm:ss"/></span>
                    </td>
                </tr>
                <tr>
                    <td align="right">
                        <label class="Validform_label">
                            返点操作人:
                        </label>
                    </td>
                    <td class="value" colspan="6">
                        <span class="">${rebate.rebateUser.userName}</span>
                    </td>
                </tr>
                <%--返点复核信息--%>
                <tr>
                    <td colspan="6" style="text-align: center">返点复核信息</td>
                </tr>
                <%--待审核--%>
                <c:if test="${rebate.rebateauditstate == 0}">
                    <tr>
                        <td align="right">
                            <label class="Validform_label">
                                复核结果:
                            </label>
                        </td>
                        <td class="value" colspan="6">
                            <select name="rebateauditstate" id="rebate_audit_state">
                                <option value="1">通过</option>
                                <option value="2">不通过</option>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td align="right">
                            <label class="Validform_label">
                                不通过原因:
                            </label>
                        </td>
                        <td class="value" colspan="6">
                            <textarea name="rebaterejectreason" id="rebatere_jectreason"
                                      style="width: 400px;height:100px"></textarea>
                            <span class="Validform_checktip" id="rebatere_jectreason_error"></span>
                        </td>
                    </tr>

                </c:if>
                <%--已经审核 显示相关信息--%>
                <c:if test="${rebate.rebateauditstate != 0}">
                    <tr>
                        <td align="right">
                            <label class="Validform_label">
                                复核结果:
                            </label>
                        </td>
                        <td class="value">
                            <c:if test="${rebate.rebateauditstate == 1}"><span class="">通过</span></c:if>
                            <c:if test="${rebate.rebateauditstate == 2}"><span class="">未通过</span></c:if>
                        </td>
                        <td align="right">
                            <label class="Validform_label">
                                复核人:
                            </label>
                        </td>
                        <td class="value">
                            <span class="">${rebate.rebateAuditUser.userName}</span>
                        </td>
                        <td align="right">
                            <label class="Validform_label">
                                复核时间:
                            </label>
                        </td>
                        <td class="value">
                            <span class=""><fmt:formatDate value='${rebate.rebatereviewtime}' type="date"
                                                           pattern="yyyy-MM-dd HH:mm:ss"/></span>
                        </td>
                    </tr>
                    <tr>
                        <td align="right">
                            <label class="Validform_label">
                                未通过原因:
                            </label>
                        </td>
                        <td class="value">
                            <textarea name="rebaterejectreason"
                                      style="width: 400px;height:100px">${rebate.rebaterejectreason}</textarea>
                        </td>
                    </tr>

                </c:if>
                <%--显示退回信息--%>
                <c:if test="${rebate.state == 1 || rebate.state == 2}">
                    <tr>
                        <td colspan="6" style="text-align: center">返点退回信息</td>
                    </tr>
                    <tr>
                        <td align="right">
                            <label class="Validform_label">
                                退回类型:
                            </label>
                        </td>
                        <td class="value">
							<span class="">
								<c:if test="${rebate.state == 1}">部分退回</c:if>
								<c:if test="${rebate.state == 2}">全部退回</c:if>
							</span>
                        </td>
                        <td align="right">
                            <label class="Validform_label">
                                退回金额:
                            </label>
                        </td>
                        <td class="value">
                            <span class="">${rebate.returnmoney}</span>
                        </td>
                        <td align="right">
                            <label class="Validform_label">
                                退回时间:
                            </label>
                        </td>
                        <td class="value">
                            <span class=""><fmt:formatDate value='${rebate.returntime}' type="date"
                                                           pattern="yyyy-MM-dd HH:mm:ss"/></span>
                        </td>
                    </tr>
                    <tr>
                        <td align="right">
                            <label class="Validform_label">
                                退回操作人:
                            </label>
                        </td>
                        <td class="value">
                            <span class="">${rebate.returnUser.userName}</span>
                        </td>
                        <td align="right">
                            <label class="Validform_label">
                                退回原因:
                            </label>
                        </td>
                        <td class="value" colspan="4">
                            <textarea name="returnReason"
                                      style="width: 400px;height:100px">${rebate.returnreason}</textarea>
                            <span class="Validform_checktip"></span>
                        </td>
                    </tr>
                    <%--退回复核信息--%>
                    <tr>
                        <td colspan="6" style="text-align: center">返点退回复核信息</td>
                    </tr>
                    <%--待审核--%>
                    <c:if test="${rebate.returnauditstate == 0}">
                        <tr>
                            <td align="right">
                                <label class="Validform_label">
                                    复核结果:
                                </label>
                            </td>
                            <td class="value" colspan="6">
                                <select name="returnauditstate" id="return_audit_state">
                                    <option value="1">通过</option>
                                    <option value="2">不通过</option>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td align="right">
                                <label class="Validform_label">
                                    不通过原因:
                                </label>
                            </td>
                            <td class="value" colspan="6">
                                <textarea name="returnrejectreason" id="return_rejectreason"
                                          style="width: 400px;height:100px"></textarea>
                                <span class="Validform_checktip"></span>
                            </td>
                        </tr>
                    </c:if>
                    <%--已经审核 显示相关信息--%>
                    <c:if test="${rebate.returnauditstate != 0}">
                        <tr>
                            <td align="right">
                                <label class="Validform_label">
                                    复核结果:
                                </label>
                            </td>
                            <td class="value">
                                <c:if test="${rebate.returnauditstate == 1}"><span class="">通过</span></c:if>
                                <c:if test="${rebate.returnauditstate == 2}"><span class="">未通过</span></c:if>
                            </td>
                            <td align="right">
                                <label class="Validform_label">
                                    复核人:
                                </label>
                            </td>
                            <td class="value">
                                <span class="">${rebate.returnAuditUser.userName}</span>
                            </td>
                            <td align="right">
                                <label class="Validform_label">
                                    复核时间:
                                </label>
                            </td>
                            <td class="value">
                                <span class=""><fmt:formatDate value='${rebate.returnreviewtime}' type="date"
                                                               pattern="yyyy-MM-dd HH:mm:ss"/></span>
                            </td>
                        </tr>
                        <tr>
                            <td align="right">
                                <label class="Validform_label">
                                    未通过原因:
                                </label>
                            </td>
                            <td class="value">
                                <textarea style="width: 400px;height:100px">${rebate.returnrejectreason}</textarea>
                            </td>
                        </tr>
                    </c:if>
                </c:if>
                <tr>
                    <c:if test="${rebate.rebateauditstate == 0 || (rebate.returnauditstate != null && rebate.returnauditstate == 0)}">
                        <td align="right">
                            <label class="Validform_label">
                                <input type="button" id="audit" value="确认"/>
                            </label>
                        </td>
                    </c:if>
                    <c:if test="${ (rebate.rebateauditstate != 0 && (rebate.returnauditstate != null && rebate.returnauditstate != 0))
                        || (rebate.rebateauditstate != 0 && (rebate.returnauditstate != null && rebate.returnauditstate != 0))
                        }">
                        <td>
                        </td>
                    </c:if>
                    <td colspan="6">
                        <label class="Validform_label">
                            <input type="button" value="返回" id="back" onclick="javascript:history.back(-1)"/>
                        </label>
                    </td>
                </tr>
            </c:if>
        </c:forEach>
    </table>
</form>
</body>
<script type="text/javascript">
    $(function () {
        mallEcardRebateReturnModule.init();
    });
    var mallEcardRebateReturnModule = (function () {
        //表单验证
        var fromValidform = function () {
            $("#rebate_return").Validform({
                tiptype: 4,
                btnSubmit: "#audit",
                ajaxPost: true,
                callback: function (data) {
                    if (data.success == true) {
                        tip(data.msg);
                        var state = $("#state").val();
                        if (state == 0) {//返点
                            window.document.location.href = 'mallEcardRebateController.do?rebatereviewlist'
                        } else {//退回
                            window.document.location.href = 'mallEcardRebateController.do?returnreviewlist'
                        }
                    } else {
                        $.messager.alert('错误', data.msg);
                    }
                }
            });
        }
        //select改变事件
        var selectChange = function () {
            var state = $("#state").val();
            if (state == 0) {//返点
                $("#rebate_audit_state").bind('change', function () {
                    var audit = $(this).val();
                    //不通过
                    if (audit == 2) {
                        $("#rebatere_jectreason").attr("datatype", "*");
                    } else {
                        $("#rebatere_jectreason").removeAttr("datatype");
                        $("#rebatere_jectreason").removeClass("Validform_error");
                        $("#rebatere_jectreason").next("span").remove();
                    }
                });
            } else {//退回
                $("#return_audit_state").bind('change', function () {
                    var audit = $(this).val();
                    //不通过
                    if (audit == 2) {
                        $("#return_rejectreason").attr("datatype", "*");
                    } else {
                        $("#return_rejectreason").removeAttr("datatype");
                        $("#return_rejectreason").removeClass("Validform_error");
                        $("#return_rejectreason").next("span").remove();
                    }
                });
            }

        }
        var module = {
            init: function () {
                fromValidform();
                selectChange();
            },
        }
        return module;
    })();

</script>